package com.googlecode.dgwt.client.dojo.data.listener;

import com.googlecode.dgwt.client.dojo.data.base.Store;

/**
 * Represents an listener that cares about data fetching on a {@link Store}.
 * 
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public interface FetchListener<Item> extends TransactionListener<Store<Item>,Item> {

    /**
     * Fired when an new item is fetched on the store. <br/>
     * The unique objective of this handler is to enable differentiate an item
     * that was added manually ({@link #onAdd(int, Object)}), from an item that
     * was fetched from server ({@link #onFetch(int, Object)}. <br/>
     * Just for transaction flow proposes.<br/>
     * <br/>
     * Note that {@link #onAdd(int, Object)} will always be called, no matter
     * if the item was fetched or not.
     * 
     * @param index
     *            item index on the store
     * @param item
     *            the item
     */
    public void onFetch(int index, Item item);

}
